const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    onLoad() {

        let myArray = [1, 2, 3, 4, 5, 2, 1];
        function getArray(array: number[]) {
            let newArray = [];
            let map = new Map();
            for (let i = 0, l = array.length; i < l; i++) {
                if(typeof map.get(array[i]) == "undefined"){
                    map.set(array[i], array[i]);
                    newArray.push(array[i]);
                }
            }
            return newArray;
        }
        console.warn(getArray(myArray));

    }

}